{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div id="alerts" class="container-wrap-table">
  <div class="row">
    <h2 class="table-title col-sm-1">{{t menu.item.alerts}}</h2>
    <div class="table-controls row col-sm-11 pull-right">
      <div class="col-sm-12">
        {{#isAuthorized "SERVICE.TOGGLE_ALERTS"}}
          {{view App.MainAlertDefinitionActionsView controllerBinding="App.router.mainAlertDefinitionActionsController"}}
        {{/isAuthorized}}
        <div class="VS-open-box pull-right">
          <button class="btn btn-default">
            <i class="icon-filter"></i>
          </button>
          <div class="popup-arrow-up hide"></div>
        </div>
      </div>
    </div>
  </div>
  <div class="row search-box-row hide">
    {{view App.MainAlertDefinitionSearchBoxView}}
  </div>
  <table class="table advanced-header-table table-hover alerts-table" id="alert-definitions-table">
    <thead>
    {{#view view.sortView classNames="label-row" contentBinding="view.filteredContent"}}
      {{view view.parentView.statusSort class="first status-sorting"}}
      {{view view.parentView.nameSort class="name-sorting"}}
      {{view view.parentView.serviceSort class="service-sorting"}}
      {{view view.parentView.lastTriggeredSort class="last-triggred-sorting"}}
      {{view view.parentView.enabledSort class="enabled-sorting"}}
    {{/view}}
    </thead>
    <tbody>
    {{#if App.router.clusterController.isAlertsLoaded}}
      {{#if view.pageContent}}
        {{#each alertDefinition in view.pageContent}}
          <tr>
            <td class="first alert-status">
              {{view App.AlertDefinitionSummary contentBinding="alertDefinition"}}
            </td>
            <td class="alert-name">
              <a href="#" {{action "gotoAlertDetails" alertDefinition}}>{{alertDefinition.label}}</a>
            </td>
            <td class="alert-service">{{alertDefinition.serviceDisplayName}}</td>
            <td class="alert-time">
              <time class="timeago" {{bindAttr data-original-title="alertDefinition.lastTriggeredFormatted"}}>{{alertDefinition.lastTriggeredAgoFormatted}}</time>
            </td>
            <td class="last toggle-state-button alert-state">
              {{view App.AlertDefinitionState contentBinding="alertDefinition"}}
            </td>
          </tr>
        {{/each}}
      {{else}}
        <tr>
          <td class="first"></td>
          <td colspan="4">
            {{t alerts.table.noAlerts}}
          </td>
        </tr>
      {{/if}}
    {{else}}
      <tr>
        <td class="first"></td>
        <td colspan="2">
          {{view App.SpinnerView}}
        </td>
        <td colspan="2"></td>
      </tr>
    {{/if}}
    </tbody>
    <tfoot>
      <tr>
        <td colspan="5">
          {{view App.PaginationView}}
        </td>
      </tr>
    </tfoot>
  </table>

</div>
